package com.xuyiwei.xblog.core.base.constant.enums;

import com.xuyiwei.xblog.core.base.constant.ConstantStatusInterface;

import java.util.HashMap;
import java.util.Map;

/**
 * 是否是菜单的枚举
 *
 * @author fengshuonan
 * @date 2017年6月1日22:50:11
 */
public enum IsMenu implements ConstantStatusInterface<Boolean,String> {
    NULL(null, ""),
    YES(true, "是"),
    NO(false, "不是"); //不是菜单的是按钮

    private Boolean key;
    private String desc;

    IsMenu(Boolean key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    static Map<Boolean, IsMenu> map = new HashMap<>();

    static {
        for (IsMenu bst : IsMenu.values()) {
            map.put(bst.key, bst);
        }
    }

    public static IsMenu convert(Boolean key) {
        IsMenu type = map.get(key);
        return (type != null) ? type : NULL;
    }

    @Override
    public Boolean getKey() {
        return key;
    }

    @Override
    public String getDesc() {
        return desc;
    }

}
